package com.koron.css2.serviceManage.mapper;

import com.koron.css2.serviceManage.bean.AdminAreaBean;
import com.koron.css2.serviceManage.bean.AdminAreaListBean;
import com.koron.css2.serviceManage.bean.AdminAreaQueryBean;
import com.koron.css2.serviceManage.bean.ConcentratorListBean;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.koron.ebs.mybatis.EnvSource;

import java.util.List;
import java.util.Map;


/**
 * 结构化地址mapper
 * 
 * @author 甄玉晴
 *
 */
@EnvSource("_default")
public interface PubAdminAreaMapper {

	/**
	 * 查询列表
	 * 
	 * @return
	 */
	List<AdminAreaListBean> list(AdminAreaBean bean);
	List<AdminAreaListBean> queryList(AdminAreaBean bean);
	List<AdminAreaListBean> queryListByName(AdminAreaBean bean);
	AdminAreaListBean queryOne(AdminAreaBean bean);
	/**
	 * 水司列表查询
	 * @param bean
	 * @return
	 */
	List<AdminAreaListBean> grouplist(AdminAreaBean bean);
	/**
	 * 根据条件获取型号信息
	 * 
	 * @return
	 */
	List<AdminAreaBean> listPaging(AdminAreaQueryBean bean);
	
	Integer add(AdminAreaBean bean);
	
	String getMaxAreaNo(@Param("areaNo") String areaNo,@Param("length") int length);

	String selectFullName(@Param("areaNo") String areaNo);
	String selectFullNameById(@Param("id") String id);

	List<AdminAreaBean> selectAdminAreaBeanByIds(@Param("idList") List<String> idList);

	String getAreaNameById(@Param("id") String id);
	
	void updateIsLeaf(Map<String,Object> params);
	
	String getNameById(@Param("parentId") String parentId);
	
	@Select("select isLeaf isLeaf from pub_admin_area where id = #{parentId}")
	String isLeaf(@Param("parentId") String parentId);
	/**
	 * 新增
	 * @param bean
	 * @return
	 */
	Integer insert(AdminAreaBean bean);
	/**
	 * 修改
	 * @param bean
	 * @return
	 */
	Integer updateArea(AdminAreaBean bean);
	
	@Delete("TRUNCATE TABLE pub_admin_area")
	void truncateAdminArea();
	/**
	 * 批量插入数据
	 * @param params
	 */
	void insertBatch(List<AdminAreaBean> params);
	
	
	public List<AdminAreaBean> listGroup(AdminAreaBean bean);
	/**
	 * 查询子节点
	 * @param group
	 * @return
	 */
	public List<AdminAreaBean> queryListById(@Param("group")String group,@Param("parentId")String parentId);
	/**
	 * 查询父节点
	 * @param group
	 * @return
	 */
	public List<AdminAreaBean> queryParentList(@Param("id")String id);
	/**
	 * 获取集中器树
	 * @param bean
	 * @return
	 */
	List<ConcentratorListBean> listConcentratorTree(AdminAreaBean bean);

	String getIdByFullName(@Param("fullName") String fullName);

	/**
	 * 删除区域
	 * @param areaNo
	 */
	void delAdminAreaByAreaNo(@Param("areaNo") String areaNo);
}
